//package com.yzf.enterprise.framework.config.shardingjdbc;
//
//
//import com.google.common.collect.Range;
//import io.shardingsphere.api.algorithm.sharding.PreciseShardingValue;
//import io.shardingsphere.api.algorithm.sharding.RangeShardingValue;
//import io.shardingsphere.api.algorithm.sharding.standard.PreciseShardingAlgorithm;
//import io.shardingsphere.api.algorithm.sharding.standard.RangeShardingAlgorithm;
//import lombok.extern.slf4j.Slf4j;
//
//import java.util.Collection;
//import java.util.LinkedHashSet;
//
///**
// * 数据库分库的策略，根据分片键，返回数据库名称
// */
//@Slf4j
//public class DBRangeShardAlgo implements RangeShardingAlgorithm<Long> {
//
//    public Collection<String> doSharding(Collection<String> collection, RangeShardingValue<Long> rangeShardingValue) {
//        log.info("This is DBRangeShardAlgo , db:" + collection);
//        log.info("This is DBRangeShardAlgo , rangeShardingValue:" + rangeShardingValue);
//
//        Collection<String> collect = new LinkedHashSet<>();
//        Range<Long> valueRange = rangeShardingValue.getValueRange();
//
//        log.info("lowerEndpoint:{}", valueRange.lowerEndpoint());
//        log.info("upperEndpoint:{}", valueRange.upperEndpoint());
//
//        for (Long i = valueRange.lowerEndpoint(); i <= valueRange.upperEndpoint(); i++) {
//            for (String dbName : collection) {
//                if (dbName.endsWith(i % collection.size() + "")) {
//                    collect.add(dbName);
//                }
//            }
//        }
//        return collect;
//    }
//
//}
